package cn.backpackerxl.easyJDBC.main;

import cn.backpackerxl.easyJDBC.util.StringUtil;

/**
 * @Author: backpackerxl
 * CreateTime: 2022/5/23
 * FileName: BasicService
 **/
public class BasicService {
    private BasicService() {
    }

    public static String save(Class<?> clazz) {
        return "\tint add(" + BasicEntity.type(clazz.getName()) + " " + StringUtil.headSmall(BasicEntity.type(clazz.getName())) + ");\n\n";
    }

    public static String update(Class<?> clazz) {
        return "\tint edit(" + BasicEntity.type(clazz.getName()) + " " + StringUtil.headSmall(BasicEntity.type(clazz.getName())) + ");\n\n";
    }

    public static String remove() {
        return "\tint delete(Long id);\n\n";
    }

    public static String findById(Class<?> clazz) {
        return "\t" + BasicEntity.type(clazz.getName()) + " selectById(Long id);\n\n";
    }

    public static String findAll(Class<?> clazz) {
        return "\tList<" + BasicEntity.type(clazz.getName()) + "> selectAll();\n\n";
    }

    public static String autoImport(Class<?> clazz) {
        return "import " + clazz.getName() + ";\n\n" + "import java.util.List;\n";
    }
}
